package com.itheima.springboottilasmanager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.springboottilasmanager.pojo.dto.GenderCount;
import com.itheima.springboottilasmanager.pojo.dto.Jobcount;
import com.itheima.springboottilasmanager.pojo.domain.Emp;
import com.itheima.springboottilasmanager.pojo.vo.QueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmpMapper extends BaseMapper<Emp> {

//多条件查询
//@Select("select e.*,d.name as deptname " +
//        "from emp e left join dept d " +
//        "on e.dept_id = d.id " +
//        "where"+" e.name like concat('%',#{name},'%') and gender=#{gender}  and entry_date between #{begin} and #{end} ")



/*
* 使用foreach循环拼
* */
    void deletbyId(@Param("ids") List<Integer> ids);

    Emp selectById(@Param("id") Integer id);

    int updateById(Emp emp1);

    @Select("select d.id  ,count(*) from emp e join  dept d \n" +
            "                         where e.dept_id  = d.id and  d.id=#{id}\n" +
            "                                                          group by d.id;")
    List<Emp> ListbyId(Integer id);
//@Select("select job,count(*) as count from emp where job is not null group by job;")
    List<Jobcount> countByJob();
//@Select("select gender as name,count(*) as value from emp where gender is not null group by gender;")
    List<GenderCount> countByGender();

@Select("select * from emp where username=#{username} ")
    Emp SelectByUsername(@Param("username") String username);
}
